import request from '@/utils/request';
import { GroupForm, GroupQuery, GroupVO } from './types';
import { AxiosPromise } from 'axios';

// 查询租户列表
export function listGroup(query: GroupQuery): AxiosPromise<GroupVO[]> {
  return request({
    url: '/system/group/list',
    method: 'get',
    params: query
  });
}

// 查询租户详细
export function getGroup(id: string | number): AxiosPromise<GroupVO> {
  return request({
    url: '/system/group/' + id,
    method: 'get'
  });
}

// 新增租户
export function addGroup(data: GroupForm) {
  return request({
    url: '/system/group',
    method: 'post',
    headers: {
      isEncrypt: true
    },
    data: data
  });
}

// 修改租户
export function updateGroup(data: GroupForm) {
  return request({
    url: '/system/group',
    method: 'put',
    data: data
  });
}

// 租户状态修改
export function changeGroupStatus(id: string | number, groupId: string | number, status: string) {
  const data = {
    id,
    groupId,
    status
  };
  return request({
    url: '/system/group/changeStatus',
    method: 'put',
    data: data
  });
}

// 删除租户
export function delGroup(id: string | number | Array<string | number>) {
  return request({
    url: '/system/group/' + id,
    method: 'delete'
  });
}
